using GrapeCity.Forguncy.CellTypes;
using GrapeCity.Forguncy.Plugin;
using System.ComponentModel;
using System.Windows;

namespace MermaidRenderer
{
    [Icon("pack://application:,,,/MermaidRenderer;component/Resources/Icon.png")]
    [Designer(typeof(MermaidRendererCellTypeDesigner))]
    public class MermaidRendererCellType : CellType
    {
        [SupportModifyByRuntimeProperty]
        [FormulaProperty(AcceptsReturn = true, CanSelectResource = false)]
        [DisplayName("图表定义文本")]
        [Description("请遵循 Mermaid 的语法; \n支持多行文本输入，设计器内 shift + enter 换行即可，无需输入换行符\\n")]
        public object MermaidDefinition { get; set; }

        public override string ToString()
        {
            return "Mermaid 渲染器";
        }
    }
    
    public class MermaidRendererCellTypeDesigner : CellTypeDesigner<MermaidRendererCellType>
    {
        public override FrameworkElement GetDrawingControl(ICellInfo cellInfo, IDrawingHelper drawingHelper)
        {
            return drawingHelper.GetHeadlessBrowserPreviewControl(); // 使用无头浏览器渲染设计时预览
        }
    }
}
